﻿namespace Service
{
	using System;
	using System.Linq;
	using System.Collections.Generic;

	public class CashTicketService:ICashTicketService
	{
		private Data.Repository.CashTicketRepository _CashTicketRepository;

		#region ICashTicketService Members

		public int CreateNewCashTicket(Data.Entity.CashTicket theNewCashTicket)
		{
			if (theNewCashTicket == null)
			{
				return -1;
			}

			if (_CashTicketRepository == null)
			{
				_CashTicketRepository = new Data.Repository.CashTicketRepository();
			}

			return _CashTicketRepository.CreateNewCashTicket(theNewCashTicket);
		}

		public IList<Data.Entity.CashTicket> GetMyCashTicket(Guid userID)
		{
			if (userID == null || Guid.Empty.Equals(userID))
			{
				return null;
			}

			if (_CashTicketRepository == null)
			{
				_CashTicketRepository = new Data.Repository.CashTicketRepository();
			}

			return _CashTicketRepository.GetMyCashTicket(userID);
		}

		public int UpdateCashTicket(Data.Entity.CashTicket theCashTicket)
		{
			if (theCashTicket == null)
			{
				return -1;
			}

			if (_CashTicketRepository == null)
			{
				_CashTicketRepository = new Data.Repository.CashTicketRepository();
			}

			return _CashTicketRepository.UpdateCashTicket(theCashTicket);
		}

		#endregion
	}
}
